package com.itheima_1;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.lang.reflect.Constructor;

public class RflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        //meothd();
       // mothed1();
        //mothed3();
        Class aCla = Class.forName("com.itheima_1.Student");
        Constructor declaredConstructor = aCla.getDeclaredConstructor(String.class);
        System.out.println(declaredConstructor);
    }

    public static void mothed3() throws ClassNotFoundException, NoSuchMethodException {
        Class ass = Class.forName("com.itheima_1.Student");
        Constructor constructor1 = ass.getConstructor();
        System.out.println(constructor1);
        Constructor constructor2 = ass.getConstructor(String.class,int.class);
        System.out.println(constructor2);
        //Student里面没有这个构造方法
        Constructor constructor3 = ass.getConstructor(int.class);
        System.out.println(constructor3);
    }

    public static void mothed1() throws ClassNotFoundException {
        Class cla= Class.forName("com.itheima_1.Student");
        Constructor[] declaredConstructors = cla.getDeclaredConstructors();
        for (Constructor declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }
    }

    public static void meothd() throws ClassNotFoundException {
        Class aClass = Class.forName("com.itheima_1.Student");
        Constructor[] constructors = aClass.getConstructors();
        for (Constructor constructor : constructors) {
            System.out.println(constructor);
        }
    }
}
